package com.hydl.power.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hydl.power.mapper.InspectionOrderMapper;
import com.hydl.power.mapper.InspectionplanMapper;
import com.hydl.power.mapper.MaintainerMapper;
import com.hydl.power.pojo.InspectionOrder;
import com.hydl.power.pojo.Inspectionplan;
import com.hydl.power.pojo.Maintainer;
import com.hydl.power.service.InspectionOrderService;
import com.hydl.power.service.InspectionplanService;
import com.hydl.power.utils.MainDemo;
import com.hydl.power.utils.Resp;
import com.hydl.power.utils.SmsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service
public class InspectionOrderServiceImpl implements InspectionOrderService {

    @Autowired
    private InspectionOrderMapper inspectionOrderMapper;

  @Override
  public int insertSelective(String projectId,String projectName,String poweroomId,String powerroomName,String result,String maintainerId,String maintainerName,String maintainerPhone,String maintainerImage,String longitude,String dimensionality) {
    String add = MainDemo.getAdd(dimensionality,longitude);
    InspectionOrder inspectionOrder = new InspectionOrder();
    inspectionOrder.setProjectId(projectId);
    inspectionOrder.setProjectName(projectName);
    inspectionOrder.setPoweroomId(poweroomId);
    inspectionOrder.setPowerroomName(powerroomName);
    inspectionOrder.setResult(result);
    inspectionOrder.setIPQCID(maintainerId);
    inspectionOrder.setIPQCNAME(maintainerName);
    inspectionOrder.setIPQCIphone(maintainerPhone);
    inspectionOrder.setMaintainerImage(maintainerImage);
    inspectionOrder.setLongitude(longitude);
    inspectionOrder.setDimensionality(dimensionality);
    inspectionOrder.setLocation(add);
    return inspectionOrderMapper.insert(inspectionOrder);
  }

  @Override
  public PageInfo<InspectionOrder> queryInspectionOrder(Integer pageNum, Integer pageSize, String startTime, String endTime, String projectId) {
      List<InspectionOrder> list = inspectionOrderMapper.queryInspectionOrder(pageNum,pageSize,startTime,endTime,projectId);
      System.out.println(list);
    return new PageInfo<>(list);
  }
}
